#include "UdpServer.hpp"
#include "Route.hpp"
#include <memory>
// int main()
// {
//     uint16_t port=8899;
//     std::string ip="127.0.0.1";
//     // std::string ip="8.8.8.8";
//     EnableScreen();
//     std::unique_ptr<UdpServer> usvr=std::make_unique<UdpServer>(ip,port);//c++14
//     usvr->InitServer();//初始化
//     usvr->Start();//启动
//     return 0;
// }

int main(int argc,char *argv[])
{
    if (argc != 2)
    {
        std::cerr << "Usage: " << argv[0] << "local_port" << std::endl;
        exit(0);
    }

    //std::string ip = argv[1];
    uint16_t port = std::stoi(argv[1]);
    
    // std::string ip="8.8.8.8";
    EnableScreen();

    Route messageRoute;
    service_t message_route=std::bind(&Route::Forward,&messageRoute,std::placeholders::_1,std::placeholders::_2,std::placeholders::_3);

    
    std::unique_ptr<UdpServer> usvr=std::make_unique<UdpServer>(message_route,port);//c++14
    usvr->InitServer();//初始化
    usvr->Start();//启动
    return 0;
}